import {WeaDialog, WeaMap,WeaLocaleProvider} from 'ecCom';
import {message} from 'antd';
import Apis from '../../../../apis/myBlog';
const getLabel = WeaLocaleProvider.getLabel;
class WeiboMapDialog extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      show: false,
      title: '',
      position: []
    }
    this.map = undefined;
  }

  render() {
    let {show, title, position} = this.state;
    return (

        <WeaDialog ecId={`${this && this.props && this.props.ecId || ''}_WeaDialog@e6zlty`} icon="icon-coms-blog" visible={show} title={getLabel(83161,"地图查看")} style={{width: 600, height: 500}}
                                          onCancel={this.close}>
          <WeaMap ecId={`${this && this.props && this.props.ecId || ''}_WeaMap@x6otxg`} position={position} title={title}/>
      </WeaDialog>

    );
  }

  open = () => {
     this.getLocation();
  }

  close = () => {
    this.setState({show: false});
  }

  getLocation = () => {
    Apis.getBlogLocations({discussId: this.props.discussId}).then((result) => {
      let loc = result.blogLocationList[0];
      loc.location = loc.location.split(',');
      // let lnglat = new AMap.LngLat(loc.location[1], loc.location[0]);
      // lnglat.offset(new AMap.Pixel(-12, -36));
        let postion_s=[parseFloat(loc.location[0]), parseFloat(loc.location[1])];
      this.setState({
          show:true,
        position: postion_s,
        title: loc.locationName
      });
    })
  }
}

export default WeiboMapDialog;